class Game extends egret.DisplayObjectContainer {
	private mc3:egret.MovieClip;
	public sc:ScrollContainer;
	private page1:Page1;
	private page2:Page2;
	private page3:Page3;
	private page4:Page4;
	private page5:Page5;
	public constructor() {
		super();

		
		MusicOnOff(true,'Jaudio');

		this.page1=new Page1();
		this.addChild(this.page1);
		
		this.page1.In();

		// RES.loadConfig("resource/default.res.json", "resource/");



		
	

		// var data = RES.getRes("mc3_json");
		// var txtr = RES.getRes("mc3_png");
		// var mcFactory:egret.MovieClipDataFactory = new egret.MovieClipDataFactory( data, txtr );
		// this.mc3 = new egret.MovieClip( mcFactory.generateMovieClipData( "mc3" ));
		// this.mc3.frameRate=12;
		// this.addChild(this.mc3);
		// this.mc3.gotoAndPlay(1,1)
		// this.mc3.addEventListener(egret.Event.COMPLETE,this.loopHandler,this);

	}
	public loadAgain()
	{
		var arr=[];
		this.page2=new Page2();
		this.page3=new Page3();
		this.page4=new Page4();
		this.page5=new Page5();
		arr.push(this.page1,this.page2,this.page3,this.page4,this.page5); 

		this.sc=new ScrollContainer();
		this.sc.init(arr,740,1136);
		this.sc.addEventListener('scrollStart',this.scrollHandler,this);
		this.sc.addEventListener('scrollComplete',this.scrollHandler,this);
		this.addChild(this.sc);

	}

	private scrollHandler(e:ScrollEvent):void
	{
		console.log(':::::::::::::::::::',e.type)
		if(e.type=='scrollStart')
		{
			console.log(':::::::::::::::::::',this.sc.pageIndex)
			this.sc.arr_child[this.sc.pageIndex].Out();
		}
		else if(e.type=='scrollComplete')
		{
			this.sc.arr_child[this.sc.pageIndex].In();
			
			if(this.sc.pageIndex==1)
			{
				MusicOnOff(true,'effect1');
			}
			else if(this.sc.pageIndex==2)
			{
				MusicOnOff(true,'effect2');
			}
			
		}
	}

	private loopHandler(e:egret.Event):void
	{
		this.mc3.frameRate=6;
		this.mc3.gotoAndPlay(20,1);
	}
}

declare function StartMusic() 
declare function MusicOnOff(bl,id) 
declare function playEffect1() 
declare function playEffect2() 